package com.jeeplus.cms.error;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author wuxilin
 */
@Controller
public class CmsErrorController {

    @RequestMapping(value = "/404",produces = {"text/html"})
    public ModelAndView errorPage404(){
        return new ModelAndView("/error/404");
    }

    @RequestMapping("/404")
    @ResponseBody
    public ResponseEntity error404(){
        return ResponseEntity.status(404).build();
    }

    @RequestMapping(value="/500",produces = {"text/html"})
    public ModelAndView errorPage500(){
        return new ModelAndView("/error/500");
    }

    @RequestMapping(value = "/500")
    @ResponseBody
    public ResponseEntity error500(){
        return ResponseEntity.status(500).build();
    }

    @RequestMapping(value = "${frontPath}/common/message")
    public String message(Model model, String messageType, String messageBody){
        model.addAttribute("messageType", messageType);
        model.addAttribute("messageBody", messageBody);
        return "/common/message";
    }
}
